package com.jy.rhin.infra.cda.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.jy.rhin.infra.cda.mzzy.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author dhl
 * @date 2023/2/10
 * @Description 门诊摘要
 */
@Mapper
@Repository
public interface MenZhenZhaiYaoMapper extends BaseMapper<Object> {

    @Select("select id, MENZHENJZLSH,                             \n" +
            "            SHUJUSCSJ,                           \n" +
            "            JIUZHENSJ,                           \n" +
            "            YISHENGDM,                           \n" +
            "            YISHENGMC,                           \n" +
            "            YILIAOJGDM,                          \n" +
            "            KESHIMC,                             \n" +
            "            YUANQUMC,                            \n" +
            "            ZHUSU,                               \n" +
            "            ZHENGZHUANGDM,                               \n" +
            "            ZHENGZHUANGMC,                               \n" +
            "            ZHENGZHUANGKSSJ,                               \n" +
            "            ZHENGZHUANGCXSJ,                               \n" +
            "            SHIFOUZZ,                               \n" +
            "            patientId,                            \n" +
            "            ZHENGJIANHM                            \n" +
            "    from YL_MENZHENJZJL  ${ew.customSqlSegment}                        ")
    MenZhenInfoVo queryMenZhenInfo(@Param(Constants.WRAPPER) QueryWrapper<MenZhenInfoVo> queryWrapper);


    @Select("select JIUZHENLSH, SHOUSHUKSRQSJ, SHOUSHUJCZBM, SHOUSHUJCZMC  from YL_SHOUSHUJL  ${ew.customSqlSegment}")
    List<ShouShuInfoVo> queryShouShuList(@Param(Constants.WRAPPER) QueryWrapper<ShouShuInfoVo> queryWrapper);


    @Select("select JIUZHENLSH,JIANCHAXMDM,JIANCHAXMMC,YICHANGBZ from YL_JIANCHABG ${ew.customSqlSegment}")
    List<JianChaInfoVo> queryJianChaList(@Param(Constants.WRAPPER) QueryWrapper<JianChaInfoVo> queryWrapper);


    @Select("select a.JIUZHENLSH, a.JIANYANBGID, b.JIANYANXMDM, b.JIANYANXMMC, b.JIANYANJGYCBZ       \n" +
            "    from YL_JIANYANBG a join yl_jianyanbgmx b  on a.JIANYANBGID = b.JIANYANBGID and a.YILIAOJGDM=b.YILIAOJGDM and a.YUANQUID=b.YUANQUID  ${ew.customSqlSegment}    ")
    List<JianYanInfoVo> queryJianYanList(@Param(Constants.WRAPPER) QueryWrapper<JianChaInfoVo> queryWrapper);


    @Select("select MENZHENLSH, ZHONGYAOLBDM,JINHOUZLFA from yl_zhiliaojl ${ew.customSqlSegment}")
    List<ZhiLiaoInfoVo> queryZhiLiaoList(@Param(Constants.WRAPPER) QueryWrapper<ZhiLiaoInfoVo> queryWrapper);


    @Select("select a.MENZHENJZLSH, a.YONGYAOTJDM ,a.YAOWUSYCJL, a.YAOWUSYJLDWDM,a.SHIYONGPCMS,b.YAOPINJXDM, b.ZHONGYAOMC, a.YONGYAOTS, a.CHUFANGTS,a.MEIRITS, a.CHUFANGFYRQSJ,a.CHUFANGKLRQSJ \n" +
            "    from yl_zhongyimzcfjl a join yl_zhongyimzcfmx b ON a.CHUFANGID = b.CHUFANGID and a.YILIAOJGDM=b.YILIAOJGDM and a.YUANQUID=b.YUANQUID ${ew.customSqlSegment}")
    List<ZhongYaoInfoVo> queryZhongYaoList(@Param(Constants.WRAPPER) QueryWrapper<ZhongYaoInfoVo> queryWrapper);


    @Select("select a.MENZHENJZLSH, b.XIANGMUMC, b.YONGYAOTJDM, b.YAOWUSYCJL , b.YAOWUSYJLDWDM, b.YAOWUSYPCDM, b.YAOPINJXDM,b.YAOPINSPM,b.YAOPINTYM,b.YONGYAOTS,b.YAOWUSYZJL,a.CHUFANGFYRQSJ,a.CHUFANGKLRQSJ \n" +
            "    from yl_xiyimjzcfjl a \n" +
            "    join yl_xiyimjzcfmxjl b ON a.CHUFANGID = b.CHUFANGID and a.YILIAOJGDM=b.YILIAOJGDM and a.YUANQUID=b.YUANQUID ${ew.customSqlSegment}")
    List<XiYaoInfoVo> queryXiYaoList(@Param(Constants.WRAPPER) QueryWrapper<XiYaoInfoVo> queryWrapper);


    @Select("select a.JIUZHENLSH, a.ZHENDUANSJ, a.ZHENDUANMC, a.ZHENDUANBM from YL_ZHENDUANMX a ${ew.customSqlSegment}")
    List<ZhenDuanInfoVo> queryZhenDuanList(@Param(Constants.WRAPPER) QueryWrapper<ZhenDuanInfoVo> queryWrapper);


    @Select("select a.MENZHENJZLSH,a.YILIAOFKFSDM, a.YILIAOFKFSMC, b.MINGXIFYLB, b.MINGXIXMJE," +
            "(select ZHIFUFS from YL_MENZHENZFMX where JIESUANLSH = a.JIESUANLSH and YILIAOJGDM=a.YILIAOJGDM and YUANQUID=a.YUANQUID limit 1) ZHIFUFS from YL_MENZHENJSJL a\n" +
            "    join YL_MENZHENJSMX b on a.JIESUANLSH = b.JIESUANLSH and a.YILIAOJGDM=b.YILIAOJGDM and a.YUANQUID=b.YUANQUID  ${ew.customSqlSegment} ")
    List<FeiYongInfoVo> queryFeiYongList(@Param(Constants.WRAPPER) QueryWrapper<FeiYongInfoVo> queryWrapper);


    @Select("select ZHUANZHENRQ, ZHUANRUKSDM zhuanZhenKS, ZHUANZHENDH, ZHUANRUJGBH, ZHUANRUJGMC, ZHUANZHENYY from JK_ZHUANZHENJL ${ew.customSqlSegment} ")
    ZhuanZhenInfoVo queryZhuanZhenInfo(@Param(Constants.WRAPPER) QueryWrapper<ZhuanZhenInfoVo> queryWrapper);

    @Select("select GEXIANGPG, CHUZHIJH, ZHILIAOYJ from YL_XIYIMJZBL ${ew.customSqlSegment} ")
    XiYiMenZhenBingLiVo queryXiYiMJZBL(@Param(Constants.WRAPPER) QueryWrapper<XiYiMenZhenBingLiVo> queryWrapper);

    @Select("select ZHILIAOYJ from YL_ZHONGYIMZBL  ${ew.customSqlSegment} ")
    ZhongYiMenZhenBingLiVo queryZhongYiMJZBL(@Param(Constants.WRAPPER) QueryWrapper<ZhongYiMenZhenBingLiVo> queryWrapper);
}
